package org.dce.screencapturer.editors;

import java.awt.BorderLayout;

import javax.swing.JColorChooser;

import org.dce.screencapturer.objects.ShapeObject;
import org.dce.screencapturer.objects.TextAttributes;

@SuppressWarnings("serial")
public class TextColorEditor extends Editor {
	
	private JColorChooser chooser = new JColorChooser();
	public TextColorEditor(ShapeObject editedObject){
		super(editedObject,"Edit text color");
		add(chooser,BorderLayout.CENTER);
	}

	@Override
	protected void readFromObject() {
		TextAttributes textAttributes = editedObject.getTextAttributes();
		chooser.setColor(textAttributes.getColor());
	}

	@Override
	protected void writeToObject() {
		TextAttributes textAttributes = (TextAttributes)editedObject.getTextAttributes().clone();
		textAttributes.setColor(chooser.getColor());
		editedObject.setTextAttributes(textAttributes);
	}
}
